<template>
    <fieldset>
        <legend>计数器</legend>
        <button @click="DECREASE_NUM(3)">-</button>
        &nbsp;
        <b>{{$store.state.num}}</b>||
        <b>{{num}}</b>
        &nbsp;
        <button @click="INCREASE_NUM">+</button>
    </fieldset>
</template>

<script>
// state 组件共享的vuex属性
// 使用辅助函数
import {mapState,mapMutations} from 'vuex'

export default{
    mounted(){
        console.log(this.$store.state);
    },
    computed:{
        ...mapState(['num'])
    },
    methods:{
        // handleMinus(){
        //     this.$store.commit("DECREASE_NUM",5)
        // },
        // handleAdd(){
        //     this.$store.commit("INCREASE_NUM")
        // }
        ...mapMutations(['INCREASE_NUM','DECREASE_NUM'])

    }
}
</script>
